#include "repairdialog.h"
#include "ui_repairdialog.h"
#include"src/mes.h"
#include<QMessageBox>

RepairDialog::RepairDialog(QWidget *parent,QString NO,QString workNumber) :
    QDialog(parent),
    ui(new Ui::RepairDialog)
{
    ui->setupUi(this);
    this->NO=NO;
    this->workNumber=workNumber;
    setWindowFlags(windowFlags()&~Qt::WindowContextHelpButtonHint);
}

RepairDialog::~RepairDialog()
{
    delete ui;
}

void RepairDialog::on_pushButton_clicked()
{
    if(Mes::getInstance()->repairIsExist(NO,workNumber)){
        ui->msg->setText("该设备正在维修中，无需重复提交");
        return;
    }

    if(ui->textEdit->toPlainText().trimmed()==""){
        ui->msg->setText("带*号项目不能为空");
        return;
    }
    QString textReason=ui->textEdit->toPlainText();

    if(Mes::getInstance()->insertUpdateRepairForm(this->NO,this->workNumber,textReason)){
        QMessageBox::information(NULL,QString("提示"),QString("提交成功        "));
        accept();
    }
}

void RepairDialog::on_pushButton_2_clicked()
{
    reject();
}
